package demo;

import com.sun.javafx.scene.control.skin.SpinnerSkin;

import java.security.PublicKey;

public class demo2 {
    public static void main(String[] args) {
        work(new Person() {
            @Override
            public void say() {
                System.out.println("呆着去");
            }
        });
        work(new Teacher());
        work(new Student());
    }
    public static void work(Person p){
       p.say();
       if(p instanceof Teacher){
           Teacher t =(Teacher) p;
           t.teach();
           t.say();
       }else if(p instanceof Student){
           Student stu = (Student) p;
           stu.say();
           stu.playGame();
       }else {
           p.say();
       }
    }
}
